<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import { KeyValues } from '../../utils/types';
import { FormInstance } from 'element-plus';
import { IStepForm } from './utils';
import { apiDict } from '../../api';
import UiPluginParamConfig from './service-config/PluginParamConfig.vue'

const formRef = ref<FormInstance>()

const form = ref<KeyValues & { params: KeyValues[] }>({
  params: []
})

const signTypes = ref([])

onMounted(() => {
  apiDict
    .getList(apiDict.DictType.SIGN_TYPE)
    .then(res => {
      signTypes.value = res.rows
    })
})

defineExpose<IStepForm>({
  getForm: () => form.value,
  validate: () => formRef.value.validate()
})
</script>

<template>
  <ElForm ref="formRef" label-width="6em" label-suffix=" :" :model="form">
    <UiPluginParamConfig v-model="form.params" />
    <ElFormItem label="签名计算">
      <ElRadioGroup v-model="form.SignatureType">
        <ElRadio v-for="_ in signTypes" :key="_.dictValue" :label="_.dictValue" />
      </ElRadioGroup>
    </ElFormItem>
  </ElForm>
</template>
